﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using BSDS.Service.Utils;
using System.Configuration;

namespace BSDS.Service
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Contains("-console"))
            {
                var application = new BsdsServiceApplication();
                application.Start();

                Console.ReadKey();
            }
            else if (args.Contains("-install"))
            {
                var serviceId = ConfigurationManager.AppSettings["serviceId"];
                var serviceDescription = ConfigurationManager.AppSettings["serviceDescription"];

                WindowsServiceUtils.InstallAndStart(serviceId, serviceDescription, Assembly.GetExecutingAssembly().Location);
            }
            else if (args.Contains("-uninstall"))
            {
                WindowsServiceUtils.Uninstall(ConfigurationManager.AppSettings["serviceId"]);
            }
            else
            {
                ServiceBase.Run(new ServiceBase[]{new BsdsService()});
            }
        }
    }
}
